load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")
load("@build_bazel_rules_apple//apple:macos.bzl", "macos_application")
load("@rules_cc//cc:defs.bzl", "cc_library", "objc_library")
load("@rules_rust//rust:defs.bzl", "rust_library")

rust_library(
    name = "rust_lib",
    srcs = ["demo.rs"],
    edition = "2018",
    tags = ["manual"],
)

# TODO: Remove this once rules_rust doesn't support bazel 5.x
cc_library(
    name = "shim",
    tags = ["manual"],
    deps = [":rust_lib"],
)

objc_library(
    name = "main_lib",
    srcs = ["main_lib.m"],
    tags = ["manual"],
    deps = [":shim"],
)

ios_application(
    name = "ios_app",
    bundle_id = "com.example.iosapp",
    families = ["iphone"],
    infoplists = ["Info.plist"],
    minimum_os_version = "13.0",
    deps = [":main_lib"],
)

macos_application(
    name = "macos_app",
    bundle_id = "com.example.macosapp",
    infoplists = ["Info.plist"],
    minimum_os_version = "10.15",
    deps = [":main_lib"],
)

platform(
    name = "macos_x86_64",
    constraint_values = [
        "@platforms//cpu:x86_64",
        "@platforms//os:macos",
    ],
)

platform(
    name = "macos_arm64",
    constraint_values = [
        "@platforms//cpu:arm64",
        "@platforms//os:macos",
    ],
)

platform(
    name = "ios_x86_64",
    constraint_values = [
        "@platforms//cpu:x86_64",
        "@platforms//os:ios",
        "@build_bazel_apple_support//constraints:simulator",
    ],
)

platform(
    name = "ios_sim_arm64",
    constraint_values = [
        "@platforms//cpu:arm64",
        "@platforms//os:ios",
        "@build_bazel_apple_support//constraints:simulator",
    ],
)

platform(
    name = "ios_arm64",
    constraint_values = [
        "@platforms//cpu:arm64",
        "@platforms//os:ios",
        "@build_bazel_apple_support//constraints:device",
    ],
)
